package com.maisonliberte.updater;

import java.util.List;

import com.maisonliberte.dao.Dao;
import com.maisonliberte.entity.TableInfo;

public class UpdaterHandler {

	public void process(){
		
		List<TableInfo> products = Dao.getInstance().selectProductSource();
		for(TableInfo tInfo : products){
			
			AbstractUpdater updater = null;
			
			if(tInfo.getSourceUrl().indexOf("bdstore.jp") > -1){
				updater = new BDUpdater(tInfo.getSourceUrl(), tInfo.getUid(), String.valueOf(tInfo.getWeight()));
			}else if(tInfo.getSourceUrl().indexOf("minne.com") > -1){
				updater = new MinneUpdater(tInfo.getSourceUrl(), tInfo.getUid(), String.valueOf(tInfo.getWeight()));
			}else if(tInfo.getSourceUrl().indexOf("stylestore.jp") > -1){
				updater = new StyleStoreUpdater(tInfo.getSourceUrl(), tInfo.getUid(), String.valueOf(tInfo.getWeight()));
			}
			
			if(updater != null){
				updater.process();
				System.out.print(String.format("%s update finish", tInfo.getSourceUrl()));
			}
		}
		
	}

}
